<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link type="text/css" rel="stylesheet" href="css/style.css"/>
    <title></title>
    <style type="text/css">
        #goPage div {
            width: 30px;
            height: 30px;
            display: inline-block;
            font-size: 11px;
            font-weight: bolder;
            border: 1px solid #b6b6b6;
            margin-left: 10px;
            cursor: pointer;
        }

        #addCate {

        }

        .toHidden {
            display: none;
        }

        .active {
            color: #ff4e00;
            font-weight: bolder;
        }

        #goPage {
            margin-top: 40px;
        }

        #goPage div:hover {
            background-color: #b6b6b6;
        }

        .myBack {
            font-weight: bold;
            background-color: #ff4e00;
        }

        .bold-border {
            border-top: 2px solid black;
        }

        th {
            width: 33%;
            font-size: 14px;
        }

        #myCate table {
            border-bottom: 2px solid black;
        }

        #myCate table td {
            border-left: 1px solid black;
            border-right: 1px solid black;
        }

        td {
            font-size: 12px;
        }
    </style>
</head>
<body>
<div class="soubg">
    <div class="sou">
        <!--Begin 所在收货地区 Begin-->
        <span class="s_city_b">
        	<span class="fl">送货至：</span>
            <span class="s_city">
            	<span>四川</span>
                <div class="s_city_bg">
                	<div class="s_city_t"></div>
                    <div class="s_city_c">
                    	<h2>请选择所在的收货地区</h2>
                        <table border="0" class="c_tab" style="width:235px; margin-top:10px;" cellspacing="0"
                               cellpadding="0">
                          <tr>
                            <th>A</th>
                            <td class="c_h"><span>安徽</span><span>澳门</span></td>
                          </tr>
                          <tr>
                            <th>B</th>
                            <td class="c_h"><span>北京</span></td>
                          </tr>
                          <tr>
                            <th>C</th>
                            <td class="c_h"><span>重庆</span></td>
                          </tr>
                          <tr>
                            <th>F</th>
                            <td class="c_h"><span>福建</span></td>
                          </tr>
                          <tr>
                            <th>G</th>
                            <td class="c_h"><span>广东</span><span>广西</span><span>贵州</span><span>甘肃</span></td>
                          </tr>
                          <tr>
                            <th>H</th>
                            <td class="c_h"><span>河北</span><span>河南</span><span>黑龙江</span><span>海南</span><span>湖北</span><span>湖南</span></td>
                          </tr>
                          <tr>
                            <th>J</th>
                            <td class="c_h"><span>江苏</span><span>吉林</span><span>江西</span></td>
                          </tr>
                          <tr>
                            <th>L</th>
                            <td class="c_h"><span>辽宁</span></td>
                          </tr>
                          <tr>
                            <th>N</th>
                            <td class="c_h"><span>内蒙古</span><span>宁夏</span></td>
                          </tr>
                          <tr>
                            <th>Q</th>
                            <td class="c_h"><span>青海</span></td>
                          </tr>
                          <tr>
                            <th>S</th>
                            <td class="c_h"><span>上海</span><span>山东</span><span>山西</span><span
                                    class="c_check">四川</span><span>陕西</span></td>
                          </tr>
                          <tr>
                            <th>T</th>
                            <td class="c_h"><span>台湾</span><span>天津</span></td>
                          </tr>
                          <tr>
                            <th>X</th>
                            <td class="c_h"><span>西藏</span><span>香港</span><span>新疆</span></td>
                          </tr>
                          <tr>
                            <th>Y</th>
                            <td class="c_h"><span>云南</span></td>
                          </tr>
                          <tr>
                            <th>Z</th>
                            <td class="c_h"><span>浙江</span></td>
                          </tr>
                        </table>
                    </div>
                </div>
            </span>
        </span>
        <!--End 所在收货地区 End-->
        <div id="thisHead">
        <span class="fr">
                <span class="fl"><span v-if="loginUser.loginName===''">你好，请<a
                        href="Login.html">登录</a>&nbsp; </span><span v-else>欢迎：<span
                        style="font-weight: bolder;color: #ff3600">{{loginUser.loginName}}</span>&nbsp;&nbsp;</span><a
                        v-if="loginUser.loginName!==''" href="#" @click.prevent="loginOut()">注销</a> <a
                        href="Regist.html" style="color:#ff4e00;">免费注册</a>&nbsp;|&nbsp;<a
                        href="Member_Order.html">我的订单</a>&nbsp;|</span>
        	<span class="ss">
                <div class="ss_list">
                	<a href="#">管理中心</a>
                    <div class="ss_list_bg">
                    	<div class="s_city_t"></div>
                        <div class="ss_list_c">
                        	<ul>
                            	<li><a href="Member_Safe.html">账户管理</a></li>
                                <li><a href="NewsList.html">资讯列表</a></li>
                                <li><a href="ProductList.html">商品列表</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="ss_list">
                	<a href="#">网站导航</a>
                    <div class="ss_list_bg">
                    	<div class="s_city_t"></div>
                        <div class="ss_list_c">
                            <ul>
                                <li><a href="Member_Collect.html">我的收藏</a></li>
                                <li><a href="CategoryList.html">全部商品</a></li>
                                <li><a href="BuyCar.html">购物车</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </span>
            <span class="fl">|&nbsp;关注我们：</span>
            <span class="s_sh"><a href="#" class="sh1">新浪</a><a href="#" class="sh2">微信</a></span>
            <span class="fr">|&nbsp;<a href="#">手机版&nbsp;<img src="images/s_tel.png" align="absmiddle"/></a></span>
        </span>
        </div>
    </div>
</div>
<div class="m_top_bg">
    <div class="top">
        <div class="m_logo"><a href="Index.html"><img src="images/logo1.png"/></a></div>
        <div class="m_search">
            <form>
                <input type="text" value="" class="m_ipt"/>
                <input type="submit" value="搜索" class="m_btn"/>
            </form>
            <span class="fl"><a href="#">咖啡</a><a href="#">iphone 6S</a><a href="#">新鲜美食</a><a href="#">蛋糕</a><a
                    href="#">日用品</a><a href="#">连衣裙</a></span>
        </div>
        <div id="myHead">
            <div class="i_car">
                <div class="car_t">购物车 [ <span>{{car.totalNum}}</span> ]</div>
                <div class="car_bg">
                    <!--Begin 购物车未登录 Begin-->
                    <div v-if="loginUser.loginName==''" class="un_login">还未登录！<a href="Login.html"
                                                                                     style="color:#ff4e00;">马上登录</a>
                        查看购物车！
                    </div>
                    <!--End 购物车未登录 End-->
                    <!--Begin 购物车已登录 Begin-->
                    <div v-else-if="car.totalPrice==0" class="un_login">暂无商品！<a href="CategoryList.html"
                                                                                    style="color:#ff4e00;">购买商品</a>
                    </div>
                    <div v-else>
                        <ul class="cars">
                            <li v-for="carDetail in carDetailList">
                                <div class="img"><a href="#"><img
                                        :src="'http://192.168.126.132:8090/easyBuy/files/'+carDetail.fileName"
                                        width="58"
                                        height="58"/></a></div>
                                <div class="name"><a href="#">{{carDetail.productName}}</a></div>
                                <div class="price"><font color="#ff4e00">￥{{ carDetail.totalPrice }}</font>
                                    X{{ carDetail.totalNum }}
                                </div>
                            </li>

                        </ul>
                        <div class="price_sum">共计&nbsp; <font color="#ff4e00">￥</font><span>{{car.totalPrice}}</span>
                        </div>
                        <div class="price_a"><a :href="'BuyCar.html?id='+car.id">去购物车结算</a></div>
                        <!--End 购物车已登录 End-->
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="i_bg bg_color">
    <!--Begin 用户中心 Begin -->
    <div class="m_content">
        <div class="m_left" id="mySlide">
            <div class="left_n">管理中心</div>
            <div class="left_m">
                <div class="left_m_t t_bg1">订单中心</div>
                <ul>
                    <li><a href="Member_Order.html">订单管理</a></li>
                    <li><a href="Member_Address.html">收货地址</a></li>
                </ul>
            </div>
            <div class="left_m">
                <div class="left_m_t t_bg3">账户中心</div>
                <ul>
                    <li><a href="Member_Safe.html">账户安全</a></li>
                    <li><a href="Member_Collect.html">我的收藏</a></li>
                </ul>
            </div>
            <div class="left_m" v-if="loginUser.type===1">
                <div class="left_m_t t_bg4">用户管理</div>
                <ul>
                    <li><a href="UserList.html">用户列表</a></li>
                </ul>
            </div>
            <div class="left_m">
                <div class="left_m_t t_bg4">资讯管理</div>
                <ul>
                    <li><a href="NewsList.html">资讯列表</a></li>
                    <li><a href="NewsAdd.html" v-if="loginUser.type===1">资讯添加</a></li>
                </ul>
            </div>
            <div class="left_m" v-if="loginUser.type===1">
                <div class="left_m_t t_bg4">商品管理</div>
                <ul>
                    <li><a href="ProductList.html">商品列表</a></li>
                    <li><a href="ProductAdd.html">商品添加</a></li>
                </ul>
            </div>
            <div class="left_m" v-if="loginUser.type===1">
                <div class="left_m_t t_bg4">分类管理</div>
                <ul>
                    <li><a href="DoCategory.html" style="color: #ff3600">分类列表</a></li>
                </ul>
            </div>
        </div>
        <!--        <div class="i_bg bg_color" style="">-->
        <!--Begin 用户中心 Begin -->
        <!--            <div class="m_content">-->
        <div class="m_right" id="myCate">
            <div class="mem_tit">分类修改列表&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p
                    style="float: right;position: relative;bottom: 10px">
                <button @click="doAdd()">新增种类</button>&nbsp;&nbsp;<button @click="doDel()">删除</button>&nbsp;&nbsp;<button
                    @click="doUpdate()">修改
            </button>
            </p>
            </div>
            <div v-if="pageInfo.pages<1">
                <p style="text-align: center ; font-weight: bolder;font-size: 16px">暂无数据</p>
            </div>
            <div v-else>
                <table border="0" class="order_tab" style="width:930px; text-align:center; margin-bottom:30px;"
                       cellspacing="0" cellpadding="0">
                    <thead>
                    <tr>
                        <th style="width: 28%">一级分类</th>
                        <th style="width: 28%">二级分类</th>
                        <th style="width: 28%">三级分类</th>
                        <!--                        <th style="width: 16%">操作</th>-->
                    </tr>
                    </thead>
                    <tbody>
                    <tr v-for="(cate, index) in pageInfo.list" :key="index"
                        :class="{'bold-border': index === 0 || cate.name1 !== pageInfo.list[index - 1].name1 }">
                        <td v-if="index === 0 || cate.name1 !== pageInfo.list[index - 1].name1"
                            style="border-right: 1px solid black; border-left: 1px solid black;">
                            <a href="" @click.prevent="selectToUpdate(cate.id1)"><span
                                    style="font-weight: bolder;font-size: 16px"><span
                                    :class="{'active': updateId===cate.id1}">{{cate.name1}}</span></span></a>
                        </td>
                        <td v-else>&nbsp;</td>
                        <td v-if="index === 0 || cate.name2 !== pageInfo.list[index - 1].name2"
                            :style="{'border-top': index === 0 || cate.name2 !== pageInfo.list[index - 1].name2 ? '2px solid black' : 'none'}">
                            <a href="#" @click.prevent="selectToUpdate(cate.id2)"><span
                                    :class="{'active': updateId===cate.id2}">{{cate.name2}}</span></a>
                        </td>
                        <td v-else>&nbsp;</td>
                        <td v-if="index === 0 || cate.name3 !== pageInfo.list[index - 1].name3"
                            :style="{'border-top': index === 0 || cate.name2 !== pageInfo.list[index - 1].name2 ? '2px solid black' : 'none'}">
                            <a href="" @click.prevent="selectToUpdate(cate.id3)"><span
                                    :class="{'active': updateId===cate.id3}">{{cate.name3}}</span></a>
                        </td>
                        <td v-else>&nbsp;</td>
                        <!--                        <td><a href="#"  @click.prevent="doDel()">删除</a>&nbsp;&nbsp;<a href="#" @click.prevent="doUpdate()">修改</a></td>-->
                    </tr>
                    </tbody>
                </table>
                <div style="text-align: center;scale: 1.2" id="goPage">
                    <span>第{{pageInfo.pageNum}}/{{pageInfo.pages}}页</span>&nbsp;&nbsp;

                    <div v-if="pageInfo.pageNum>1" @click="nextPage('home')">首页</div>
                    <div v-if="pageInfo.pageNum>1" @click="nextPage('pre')">上页</div>
                    <div v-for="toPage in pageInfo.navigatepageNums" @click="doInit(toPage, 8)"
                         :class="{ myBack: currentPage === toPage }">{{toPage}}
                    </div>
                    <div v-if="pageInfo.pageNum<pageInfo.pages" @click.prevent="nextPage('next')">下页</div>
                    <div v-if="pageInfo.pageNum<pageInfo.pages" @click.prevent="nextPage('end')">尾页</div>
                </div>
            </div>

            <!--            增加模块-->
            <div :class="{ 'toHidden':addIsNone}"
                 style="margin-left: 200px;margin-top: 100px;scale: 1.2;border: 1px solid black;width: 300px">
                <p style="text-align: center;font-weight: bolder">新增种类：</p>
                <p>
                    分类级别：&nbsp;<select v-model="category.type">
                    <option value="0">--请选择--</option>
                    <option value="1">一级分类</option>
                    <option value="2">二级分类</option>
                    <option value="3">三级分类</option>
                </select>
                </p>

                <div v-if="category.type==1">
                    <p>
                        名称：&nbsp;<input type="text" v-model="category.name"/>(必填)
                    </p>
                </div>
                <div v-if="category.type==2">
                    一级类别：<select v-model="category.parentId">
                    <option value="-1">--请选择--</option>
                    <option v-if="myType.type==1" v-for="myType in category.list" :value="myType.id">{{myType.name}}
                    </option>
                </select>
                    <p>
                        名称：&nbsp;<input type="text" v-model="category.name"/>(必填)
                    </p>
                </div>
                <div v-if="category.type==3">
                    一级类别：<select v-model="category.parentId">
                    <option value="-1">--请选择--</option>
                    <option v-if="myType.type==1" v-for="myType in category.list" :value="myType.id">{{myType.name}}
                    </option>
                </select>
                    <p :class="{'toHidden':category.isNone}">
                        <span>二级分类：</span>
                        <select v-model="category.secondCategoryId">
                            <option value="-1">--请选择--</option>
                            <option v-if="myType.parentId==category.parentId"
                                    v-for="myType in category.list" :value="myType.id">{{myType.name}}
                            </option>
                        </select>
                    <p>
                        名称：&nbsp;<input type="text" v-model="category.name"/>(必填)
                    </p>
                </div>
                <p style="text-align: center">
                    <button @click="toAdd()">确认添加</button>
                </p>
            </div>


            <!--            修改模块-->
            <div v-if="updateData.type==3" :class="{ 'toHidden':updIsNone}"
                 style="margin-left: 200px;margin-top: 100px;scale: 1.2;border: 1px solid black;width: 300px">
                <p>一级分类：
                    <select v-model="updateData.grandParentId" disabled>
                        <option v-for="myCate in category.list" v-if="myCate.type==1" :value="myCate.id">
                            {{myCate.name}}
                        </option>
                    </select></p>
                <p>
                    二级分类：
                    <select v-model="updateData.parentId">{{updateData.parentId}}
                        <option v-for="myCate in category.list"
                                v-if="myCate.type==2&&myCate.parentId==updateData.grandParentId" :value="myCate.id">
                            {{myCate.name}}
                        </option>
                    </select></p>
                <p>名称：<input type="text" v-model="updateData.name"/></p>
                <p style="text-align: center">
                    <button @click="updateCate()">确认修改</button>
                </p>
            </div>

            <div v-if="updateData.type==2" :class="{ 'toHidden':updIsNone}"
                 style="margin-left: 200px;margin-top: 100px;scale: 1.2;border: 1px solid black;width: 300px">
                <p>一级分类：
                    <select v-model="updateData.parentId">
                        <option v-for="myCate in category.list" v-if="myCate.type==1" :value="myCate.id">
                            {{myCate.name}}
                        </option>
                    </select></p>
                <p>名称：<input type="text" v-model="updateData.name"/></p>
                <p style="text-align: center">
                    <button @click="updateCate()">确认修改</button>
                </p>
            </div>
            <div v-if="updateData.type==1" :class="{ 'toHidden':updIsNone}"
                 style="margin-left: 200px;margin-top: 100px;scale: 1.2;border: 1px solid black;width: 300px">
                <p>一级分类：
                    名称：<input type="text" v-model="updateData.name"/></p>
                <p style="text-align: center">
                    <button @click="updateCate()">确认修改</button>
                </p>
            </div>
        </div>
    </div>
    <!--End 用户中心 End-->
    <!--Begin Footer Begin -->
    <div class="b_btm_bg b_btm_c">
        <div class="b_btm">
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;"
                   cellspacing="0" cellpadding="0">
                <tr>
                    <td width="72"><img src="images/b1.png" width="62" height="62"/></td>
                    <td><h2>正品保障</h2>正品行货 放心购买</td>
                </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;"
                   cellspacing="0" cellpadding="0">
                <tr>
                    <td width="72"><img src="images/b2.png" width="62" height="62"/></td>
                    <td><h2>满38包邮</h2>满38包邮 免运费</td>
                </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;"
                   cellspacing="0" cellpadding="0">
                <tr>
                    <td width="72"><img src="images/b3.png" width="62" height="62"/></td>
                    <td><h2>天天低价</h2>天天低价 畅选无忧</td>
                </tr>
            </table>
            <table border="0" style="width:210px; height:62px; float:left; margin-left:75px; margin-top:30px;"
                   cellspacing="0" cellpadding="0">
                <tr>
                    <td width="72"><img src="images/b4.png" width="62" height="62"/></td>
                    <td><h2>准时送达</h2>收货时间由你做主</td>
                </tr>
            </table>
        </div>
    </div>
    <div class="b_nav">
        <dl>
            <dt><a href="#">新手上路</a></dt>
            <dd><a href="#">售后流程</a></dd>
            <dd><a href="#">购物流程</a></dd>
            <dd><a href="#">订购方式</a></dd>
            <dd><a href="#">隐私声明</a></dd>
            <dd><a href="#">推荐分享说明</a></dd>
        </dl>
        <dl>
            <dt><a href="#">配送与支付</a></dt>
            <dd><a href="#">货到付款区域</a></dd>
            <dd><a href="#">配送支付查询</a></dd>
            <dd><a href="#">支付方式说明</a></dd>
        </dl>
        <dl>
            <dt><a href="#">会员中心</a></dt>
            <dd><a href="#">资金管理</a></dd>
            <dd><a href="#">我的收藏</a></dd>
            <dd><a href="#">我的订单</a></dd>
        </dl>
        <dl>
            <dt><a href="#">服务保证</a></dt>
            <dd><a href="#">退换货原则</a></dd>
            <dd><a href="#">售后服务保证</a></dd>
            <dd><a href="#">产品质量保证</a></dd>
        </dl>
        <dl>
            <dt><a href="#">联系我们</a></dt>
            <dd><a href="#">网站故障报告</a></dd>
            <dd><a href="#">购物咨询</a></dd>
            <dd><a href="#">投诉与建议</a></dd>
        </dl>
        <div class="b_tel_bg">
            <a href="#" class="b_sh1">新浪微博</a>
            <a href="#" class="b_sh2">腾讯微博</a>
            <p>
                服务热线：<br/>
                <span>400-123-4567</span>
            </p>
        </div>
        <div class="b_er">
            <div class="b_er_c"><img src="images/er.gif" width="118" height="118"/></div>
            <img src="images/ss.png"/>
        </div>
    </div>
    <div class="btmbg">
        <div class="btm">
            备案/许可证编号：蜀ICP备12009302号-1-www.dingguagua.com Copyright © 2015-2018 尤洪商城网 All Rights Reserved.
            复制必究 , Technical Support: Dgg Group <br/>
            <img src="images/b_1.gif" width="98" height="33"/><img src="images/b_2.gif" width="98" height="33"/><img
                src="images/b_3.gif" width="98" height="33"/><img src="images/b_4.gif" width="98" height="33"/><img
                src="images/b_5.gif" width="98" height="33"/><img src="images/b_6.gif" width="98" height="33"/>
        </div>
    </div>
    <!--End Footer End -->
</div>
<script type="text/javascript" src="js/axios.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/vue.min.js"></script>
<script type="text/javascript" src="js/car.js"></script>
<script type="text/javascript">
    const thisVue = new Vue({
        el: '#thisHead',
        data: {
            loginUser: {
                userId: '',
                loginName: ''
            }
        },methods:{
            loginOut: function () {
                window.sessionStorage.clear();
                axios({
                    url:'/api/user/exit'
                }).then(rs=>{
                    if (rs.data.code===200){
                        alert("注销成功!")
                    }else {
                        alert("注销失败！")
                    }
                })
            },
        },
        created: function () {
            let token = window.sessionStorage.getItem('token');
            if (token === '' || token === null) {
                console.log("未登录")
            } else {
                axios({
                    url: '/api/user/findUserFromRedis'
                }).then(rs => {
                    if (rs.data.code === 200) {
                        this.loginUser.userId = rs.data.user.id;
                        this.loginUser.loginName = rs.data.user.loginName;
                    }
                })
            }
        }
    })

    const myVue = new Vue({
        el: '#myCate',
        data: {
            category: {
                type: '0',
                parentId: '-1',
                name: '',
                list: '',
                isNone: true,//表示二级目录是否要呈现出来
                secondCategoryId: '-1'
            },
            pageInfo: '',
            currentPage: 1,
            updateId: 0,
            addIsNone: true,
            updIsNone: true,
            updateData: {
                name: '',
                parentId: '',
                type: '',
                id: '',
                grandParentId: '-1'
            }
        },
        methods: {
            updateCate: function () {
                const name = myVue.updateData.name;
                const parentId = myVue.updateData.parentId;
                const type = myVue.updateData.type;
                const id = myVue.updateData.id;
                // alert(name + "  " + parentId + "  " + type + "  " + id)
                axios({
                    url: '/api/type/updateType',
                    params: {
                        name, parentId, id
                    }
                }).then(function (rs) {
                    if (rs.data.isUpd === true) {
                        alert("修改成功！")
                        myVue.updIsNone = true
                        myVue.updateId = 0
                        myVue.doInit(1, 8)
                    } else {
                        alert("修改失败！")
                    }
                })
            },
            toAdd: function () {
                var myParentId = myVue.category.parentId;
                var name = myVue.category.name;
                var type = myVue.category.type;
                if (name === '' || type === 0) {
                    alert("内容有空，请继续填写！")
                    return
                }
                if (type != 1 && myParentId === '') {
                    alert("父级种类不能为空,请继续填写！")
                    return;
                }
                if (type == 1) {
                    myParentId = 0;
                }
                if (type == 3) {
                    myParentId = myVue.category.secondCategoryId
                }
                if (myParentId == -1) {
                    alert("请填写完整内容！");
                    return;
                }
                axios({
                    url: '/api/type/getCategory',
                    params: {
                        parentId: myParentId, name
                    }
                }).then(function (rs) {
                    if (rs.data.category === null) {
                        axios({
                            url: '/api/type/addType',
                            params: {
                                parentId: myParentId, name, type
                            }
                        }).then(function (rs) {
                            if (rs.data.isAdd === true) {
                                alert("添加成功！");
                                myVue.addIsNone = true;
                                myVue.category.parentId = '-1'
                                myVue.category.type = '0'
                                myVue.category.name = ''
                                myVue.category.secondCategoryId = '-1'
                                myVue.doInit(1, 8)
                            }
                        })
                    } else {
                        alert("种类名不可重复，请重新输入！")
                    }

                })
            },
            doAdd: function () {
                myVue.updIsNone = true;
                myVue.addIsNone = !myVue.addIsNone;
            },
            selectToUpdate: function (id) {
                this.updateId = id;
            },
            nextPage: function (opr) {
                let pageNum = 1;
                switch (opr) {
                    case 'pre':
                        pageNum = this.pageInfo.hasPreviousPage ? this.pageInfo.prePage : 1;
                        break;
                    case 'next':
                        pageNum = this.pageInfo.hasNextPage ? this.pageInfo.nextPage : this.pageInfo.pages;
                        break;
                    case 'end':
                        pageNum = this.pageInfo.pages;
                        break;
                }
                this.currentPage = pageNum;
                this.doInit(pageNum, 8);
            },
            doUpdate: function () {
                myVue.addIsNone = true
                const id = myVue.updateId;
                if (id === 0) {
                    alert("请点击分类来确认修改的对象！")
                    return
                }
                myVue.updIsNone = false
                this.getAllList(id);
            },
            doDel: function () {
                const id = myVue.updateId;
                if (id === 0) {
                    alert("请点击分类来确认删除的对象！")
                    return
                }
                axios({
                    url: '/api/type/findProduct',
                    params: {
                        id
                    }
                }).then(function (rs) {
                    if (rs.data.isFind === true) {
                        alert("该分类下有商品信息，不可删除！");
                        return;
                    }
                    axios({
                        url: '/api/type/findSon',
                        params: {
                            id
                        }
                    }).then(function (rs) {
                        if (rs.data.hasSon === true) {
                            alert("存在子类，不能删除！")
                            return;
                        }
                        const isDel = window.confirm("确认删除id为" + id + "的数据吗");
                        if (!isDel) {
                            return;
                        }
                        axios({
                            url: '/api/type/delType',
                            params: {
                                id: myVue.updateId
                            }
                        }).then(function (rs) {
                            if (rs.data.isDel === true) {
                                alert("删除成功！")
                                myVue.doInit(1, 8);
                                myVue.updateId = 0;
                            } else {
                                alert("删除失败！")
                            }
                        })
                    })
                })
            },
            doInit: function (pageNum, pageSize) {
                axios({
                    url: '/api/type/getList',
                    params: {}
                }).then(function (rs) {
                    myVue.category.list = rs.data.typeList;
                    axios({
                        url: '/api/type/selectMySon',
                        params: {
                            pageNum, pageSize
                        }
                    }).then(function (rs) {
                        myVue.currentPage = pageNum;
                        myVue.pageInfo = rs.data.pageInfo;
                        console.log(myVue.category.list)
                    })
                });

            },
            getAllList: function (id) {
                axios({
                    url: '/api/type/getCategory',
                    params: {
                        id
                    }
                }).then(function (rs) {
                    myVue.updateData.id = rs.data.category.id
                    myVue.updateData.name = rs.data.category.name
                    myVue.updateData.parentId = rs.data.category.parentId
                    myVue.updateData.type = rs.data.category.type
                    if (myVue.updateData.type == 3) {
                        axios({
                            url: '/api/type/getParent',
                            params: {
                                id: myVue.updateData.id
                            }
                        }).then(function (rs) {
                            myVue.updateData.grandParentId = rs.data.myParent.id;
                        })
                    }
                })
            }
        },
        created: function () {
            this.doInit(1, 8)
        },
        watch: {
            'category.parentId': {
                handler(newValue) {
                    const parentId = myVue.category.parentId;
                    if (parentId != -1) {
                        myVue.category.isNone = false
                    } else {
                        myVue.category.isNone = true
                    }
                }
            }
        }
    })

    new Vue({
        el: '#mySlide',
        data: {
            loginUser: {
                userId: '',
                loginName: '',
                type: ''
            }
        },
        created: function () {
            let token = window.sessionStorage.getItem('token');
            if (token === '' || token === null) {
                console.log("未登录")
            } else {
                axios({
                    url: '/api/user/findUserFromRedis'
                }).then(rs => {
                    if (rs.data.code === 200) {
                        this.loginUser.userId = rs.data.user.id;
                        this.loginUser.loginName = rs.data.user.loginName;
                        this.loginUser.type = rs.data.user.type;
                        if (rs.data.user.type===0){
                            alert("权限不足！")
                            window.location='Member_Safe.html'
                            return
                        }
                    }
                })
            }
        }
    })
</script>
</body>
</html>